﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Drawing;

namespace Spencen.Mobile.UI.Animations
{
    public class ColorAnimation : Animation<Color>
    {
        public ColorAnimation( object target, string propertyName, TimeSpan duration )
            : base(target, propertyName, duration)
        {
        }

        public override Color CurrentValue
        {
            get
            {
                return Color.FromArgb(
                    Math.Min( 255, Math.Max( 0, OriginalValue.R + (int)( ( FinalValue.R - OriginalValue.R ) * AdjustedPercentageComplete ) ) ),
                    Math.Min( 255, Math.Max( 0, OriginalValue.G + (int)( ( FinalValue.G - OriginalValue.G ) * AdjustedPercentageComplete ) ) ),
                    Math.Min( 255, Math.Max( 0, OriginalValue.B + (int)( ( FinalValue.B - OriginalValue.B ) * AdjustedPercentageComplete ) ) ) );
            }
        }
    }
}
